import React from 'react';
import {Select} from 'antd';

const Option = Select.Option;

export default {
    formateDate(time) {
        if (!time) {
            return '';
        }
        let date = new Date(time);
        return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + " "+ date.getHours() + ':' + date.getMinutes() + ":" + date.getSeconds();
    },
    // 项目分页
    pagination(data,callback) {
        let page = {
            onChange: (current) => {
                callback(current)
            },
            current:data.page,
            pageSize:data.page_size,
            total:data.total,
            showTotal: () => {
                return `共${data.total}条`
            },
            showQuickJumper:true
        };
        return page;
    },
    // OptionList 公共form
    getOptionList(data) {
        if(!data) {
            return [];
        }
        let options = [];
        data.map(d=> {
            return options.push(<Option value={d.id} key={d.id + Math.random()*1000}>{d.name}</Option>)
        });
        return options
    },
    //  ETable 行点击通用函数
    // updateSelectedItem(selectedRowKeys, selectedRows, selectedIds) {
    //     if (selectedIds) {
    //         this.setState({
    //             selectedRowKeys,
    //             selectedIds: selectedIds,
    //             selectedItem: selectedRows
    //         })
    //     } else {
    //         this.setState({
    //             selectedRowKeys,
    //             selectedItem: selectedRows
    //         })
    //     }
    // },
}
